package org.example.Command;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor
@AllArgsConstructor
@Data
public abstract class Message implements Serializable {
    private static final long serialVersionUID = 1L;

    Integer type;

    Integer SequenceId;


    final static Integer COMMON_MESSAGE = 0;
    final static Integer SEND_COMMAND = 1;
    final static Integer RECV_COMMAND = 2;
    final static Integer SHOW_COMMAND = 3;
    final static Integer CLEAR_COMMAND = 4;
    final static Integer HELP_COMMAND = 5;
    final static Integer FILE = 6;
    private static final Map<Integer, Class<? extends Message>> messageClasses = new HashMap<>();
    static {
        messageClasses.put(COMMON_MESSAGE, CommonMessage.class);
        messageClasses.put(SEND_COMMAND, SendMessage.class);
        messageClasses.put(RECV_COMMAND, RecvMessage.class);
        messageClasses.put(SHOW_COMMAND, ShowMessage.class);
        messageClasses.put(FILE, FileMessage.class);
    }
    public static Class<? extends Message> getMessageClass(byte messageType) {
        return messageClasses.get(Integer.valueOf(messageType));
    }

}
